﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CCWin;

namespace ECode.ModbusTester.CSkinUI
{
    public partial class FrmMain : CCSkinMain
    {
        public FrmMain()
        {
            InitializeComponent();
        }

        private void FrmMain_SysBottomClick(object sender, CCWin.SkinControl.SysButtonEventArgs e)
        {
             if (e.SysButton.Name == "SysTools") {
                Point l = PointToScreen(e.SysButton.Location);
                l.Y += e.SysButton.Size.Height + 1;
                MenuSysButtonItems.Show(l);
            }
        }

        private void MenuSysButtonItems_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Name.Equals("MenuItemModbus"))
            {
                var @checked=(e.ClickedItem as ToolStripMenuItem).Checked;                
                (e.ClickedItem as ToolStripMenuItem).Checked = !@checked;
                GbModbus.Visible = !@checked;
                Width = !@checked ? Width + GbModbus.Width : Width - GbModbus.Width;
            }
        }

        private void FrmMain_Shown(object sender, EventArgs e)
        {
            GbModbus.Hide();
            Width -= GbModbus.Width;
        }
    }
}
